package com.smart.community.commons.constants;

/**
 * 请求头常量定义
 * @author Wu.Liang
 * @since 2024-12-19
 * @version 1.0.0
 */
public class RequestHeaderConstants {
    
    // ==================== 用户信息请求头 ====================
    
    /**
     * 用户ID请求头
     */
    public static final String USER_ID = "X-User-Id";
    
    /**
     * 用户名称请求头
     */
    public static final String USER_NAME = "X-User-Name";
    
    /**
     * 真实姓名请求头
     */
    public static final String REAL_NAME = "X-Real-Name";
    
    /**
     * 用户角色请求头
     */
    public static final String USER_ROLE = "X-User-Role";
    
    /**
     * 用户类型请求头
     */
    public static final String USER_TYPE = "X-User-Type";
    
    /**
     * 用户权限请求头
     */
    public static final String USER_PERMISSIONS = "X-User-Permissions";
    
    /**
     * 超级管理员标识请求头
     */
    public static final String SUPER_ADMIN = "X-Super-Admin";
    
    // ==================== 业务相关请求头 ====================
    
    /**
     * 租户ID请求头
     */
    public static final String TENANT_ID = "X-Tenant-Id";
    
    /**
     * 物业公司ID请求头
     */
    public static final String PROPERTY_COMPANY_ID = "X-Property-Company-Id";
    
    /**
     * 社区ID请求头
     */
    public static final String COMMUNITY_ID = "X-Community-Id";
    
    /**
     * 区域ID请求头
     */
    public static final String REGION_ID = "X-Region-Id";
    
    /**
     * 楼栋ID请求头
     */
    public static final String BUILDING_ID = "X-Building-Id";
    
    /**
     * 单元ID请求头
     */
    public static final String UNIT_ID = "X-Unit-Id";
    
    /**
     * 房间ID请求头
     */
    public static final String ROOM_ID = "X-Room-Id";
    
    // ==================== 系统相关请求头 ====================
    
    /**
     * 请求来源请求头
     */
    public static final String REQUEST_SOURCE = "X-Request-Source";
    
    /**
     * 请求追踪ID请求头
     */
    public static final String TRACE_ID = "X-Trace-Id";
    
    /**
     * 请求ID请求头
     */
    public static final String REQUEST_ID = "X-Request-Id";
    
    /**
     * 会话ID请求头
     */
    public static final String SESSION_ID = "X-Session-Id";
    
    /**
     * 设备ID请求头
     */
    public static final String DEVICE_ID = "X-Device-Id";
    
    /**
     * 客户端版本请求头
     */
    public static final String CLIENT_VERSION = "X-Client-Version";
    
    /**
     * 客户端类型请求头
     */
    public static final String CLIENT_TYPE = "X-Client-Type";
    
    /**
     * 平台类型请求头
     */
    public static final String PLATFORM = "X-Platform";
    
    /**
     * 语言请求头
     */
    public static final String LANGUAGE = "X-Language";
    
    /**
     * 时区请求头
     */
    public static final String TIMEZONE = "X-Time-Zone";
    
    // ==================== 认证授权请求头 ====================
    
    /**
     * 授权令牌请求头
     */
    public static final String AUTHORIZATION = "Authorization";
    
    /**
     * Token请求头
     */
    public static final String TOKEN = "X-Token";
    
    /**
     * 验证码请求头
     */
    public static final String CAPTCHA = "X-Captcha";
    
    /**
     * 验证码ID请求头
     */
    public static final String CAPTCHA_ID = "X-Captcha-Id";
    
    /**
     * 签名请求头
     */
    public static final String SIGNATURE = "X-Signature";
    
    /**
     * 时间戳请求头
     */
    public static final String TIMESTAMP = "X-Timestamp";
    
    /**
     * 随机数请求头
     */
    public static final String NONCE = "X-Nonce";
    
    // ==================== 安全相关请求头 ====================
    
    /**
     * 操作类型请求头
     */
    public static final String OPERATION_TYPE = "X-Operation-Type";
    
    /**
     * 操作人ID请求头
     */
    public static final String OPERATOR_ID = "X-Operator-Id";
    
    /**
     * 操作时间请求头
     */
    public static final String OPERATION_TIME = "X-Operation-Time";
    
    // ==================== 标准HTTP请求头 ====================
    
    /**
     * 内容类型请求头
     */
    public static final String CONTENT_TYPE = "Content-Type";
    
    /**
     * 用户代理请求头
     */
    public static final String USER_AGENT = "User-Agent";
    
    /**
     * 真实IP请求头
     */
    public static final String REAL_IP = "X-Real-IP";
    
    /**
     * 转发IP请求头
     */
    public static final String FORWARDED_FOR = "X-Forwarded-For";
    
    // ==================== 请求类型标识 ====================
    
    /**
     * 内部请求标识
     */
    public static final String INTERNAL_REQUEST = "internal";
    
    /**
     * 外部请求标识
     */
    public static final String EXTERNAL_REQUEST = "external";
    
    // ==================== 工具方法 ====================
    
    /**
     * 获取所有用户信息请求头
     * 
     * @return 用户信息请求头数组
     */
    public static String[] getUserInfoHeaders() {
        return new String[]{
            USER_ID, USER_NAME, REAL_NAME, USER_TYPE, USER_ROLE, 
            USER_PERMISSIONS, SUPER_ADMIN, PROPERTY_COMPANY_ID, COMMUNITY_ID
        };
    }
    
    /**
     * 获取所有业务请求头
     * 
     * @return 业务请求头数组
     */
    public static String[] getBusinessHeaders() {
        return new String[]{
            TENANT_ID, PROPERTY_COMPANY_ID, COMMUNITY_ID, REGION_ID, 
            BUILDING_ID, UNIT_ID, ROOM_ID
        };
    }
    
    /**
     * 获取所有系统请求头
     * 
     * @return 系统请求头数组
     */
    public static String[] getSystemHeaders() {
        return new String[]{
            REQUEST_SOURCE, TRACE_ID, REQUEST_ID, SESSION_ID, DEVICE_ID,
            CLIENT_VERSION, CLIENT_TYPE, PLATFORM, LANGUAGE, TIMEZONE
        };
    }
    
    /**
     * 获取所有认证请求头
     * 
     * @return 认证请求头数组
     */
    public static String[] getAuthHeaders() {
        return new String[]{
            AUTHORIZATION, TOKEN, CAPTCHA, CAPTCHA_ID, SIGNATURE, 
            TIMESTAMP, NONCE
        };
    }
    
    /**
     * 获取所有安全请求头
     * 
     * @return 安全请求头数组
     */
    public static String[] getSecurityHeaders() {
        return new String[]{
            OPERATION_TYPE, OPERATOR_ID, OPERATION_TIME, SUPER_ADMIN
        };
    }
    
    /**
     * 检查是否为内部请求
     * 
     * @param requestSource 请求来源
     * @return 是否为内部请求
     */
    public static boolean isInternalRequest(String requestSource) {
        return INTERNAL_REQUEST.equals(requestSource);
    }
    
    /**
     * 检查是否为外部请求
     * 
     * @param requestSource 请求来源
     * @return 是否为外部请求
     */
    public static boolean isExternalRequest(String requestSource) {
        return EXTERNAL_REQUEST.equals(requestSource);
    }
    
    /**
     * 私有构造函数，防止实例化
     */
    private RequestHeaderConstants() {
        throw new UnsupportedOperationException("常量类不能实例化");
    }
} 